package main

import (
	"fmt"
)




func main(){
	fmt.Println(add(1,2,3))

	//声明时数组不能使用固定的长度，如xs :=  [3]int {10,11,12}则会报错
	xs :=  []int {10,11,12}
	fmt.Println(add(xs ...))

	add:= func(x,y int) int {
		return x+y
	}
	fmt.Println(add(10,20))

	generator:= id_generator()
	fmt.Printf("第一次生成:%d\n",generator())
	fmt.Printf("第二次生成:%d",generator())

}

//可变参数
func add(params ... int) int {
	total :=0
	for _, x:=range params{
		total+=x
	}
	return total
}

//返回函数
func id_generator() func() uint{
	x:= uint(0)
	return func() (ret uint){
		ret = x
		x+=2
		return
	}
}





